package com.borko.healthcare.entities.beans;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import com.borko.healthcare.entities.interfaces.MedicineOrder;
import com.borko.healthcare.entities.interfaces.Order;
import com.borko.healthcare.entities.interfaces.Pharmacist;

@Entity(name = "order")
@Table(name = "ORDERS")
public class OrderBean implements Order {
	
	@Id @GeneratedValue
	@Column(name = "ORDER_ID")
	private int id;
	
	@OneToMany(targetEntity = MedicineOrderBean.class, mappedBy="order")
	@LazyCollection(LazyCollectionOption.FALSE)
	private List<MedicineOrder> medicineOrders;
	
	private int qty;
	private double price;
	
	@ManyToOne(targetEntity = PharmacistBean.class, optional = true)
	private Pharmacist pharmacist;
	
	public OrderBean() {
		medicineOrders = new ArrayList<MedicineOrder>();
		pharmacist = new PharmacistBean();
	}

	public int getId() {
		return id;
	}

	public List<MedicineOrder> getMedicineOrders() {
		return medicineOrders;
	}

	public void setMedicineOrders(List<MedicineOrder> medicineOrders) {
		this.medicineOrders = medicineOrders;
	}

	public int getQty() {
		return qty;
	}

	public void setQty(int qty) {
		this.qty = qty;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public Pharmacist getPharmacist() {
		return pharmacist;
	}

	public void setPharmacist(Pharmacist pharmacist) {
		this.pharmacist = pharmacist;
	}

}
